package com.genius.unite_platform.storedevice.controller;


import javax.servlet.http.HttpSession;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.genius.adminmanager.other.entity.ResponseJson;
import com.genius.unite_platform.storedevice.service.StoreDeviceService;
import com.genius.workflow.log.ControllerLog;

@Controller
public class StoreDeviceEditController {

    @Autowired
    @Qualifier("StoreDeviceEditService")
    private   StoreDeviceService  StoreDeviceEditService;
	/**
	 * 跳转到新的编辑页面
	 */
	//@RequiresPermissions("0d92759e06bc41998b7d704ebf1d2abf")
	@PostMapping("/storedevice/toEdit")
	public String toEdit(){	 
			return "/views/unite_platform/storedevice/insert";		
	}
	/**
	 * 编辑操作
	 * @param session
	 * @return
	 * @throws Exception
	 */
	@ControllerLog(description="配置")
	@PostMapping("/storedevice/edit")
	@ResponseBody
	public JSONObject edit(@RequestBody JSONObject json,HttpSession session){
		JSONObject response = new JSONObject();
    	response.put(ResponseJson.code, 0);
    	response = StoreDeviceEditService.edit(json, response,session);
		return response;
	}
	
	@GetMapping("/storedevice/getStoreDevice")
	@ResponseBody
    public JSONArray getDeviceModelList(String storeno) {	
        return StoreDeviceEditService.getStoreDevice(storeno);
    }
}

